package cn.bugstack.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: ts
 * @description
 * @create: 2025/2/25 16:49
 */
@Configuration
public class RabbitMQConfig {
    // 定义Topic Exchange
    @Bean
    public TopicExchange activitySkuStockZeroExchange() {
        return new TopicExchange("activity_sku_stock_zero");
    }

    @Bean
    public TopicExchange sendAwardExchange() {
        return new TopicExchange("send_award");
    }

    @Bean
    public TopicExchange sendRebateExchange() {
        return new TopicExchange("send_rebate");
    }

    @Bean
    public TopicExchange creditAdjustSuccessExchange() {
        return new TopicExchange("credit_adjust_success");
    }

    // 定义Queue
    @Bean
    public Queue activitySkuStockZeroQueue() {
        return new Queue("activity_sku_stock_zero_queue");
    }

    @Bean
    public Queue sendAwardQueue() {
        return new Queue("send_award_queue");
    }

    @Bean
    public Queue sendRebateQueue() {
        return new Queue("send_rebate_queue");
    }

    @Bean
    public Queue creditAdjustSuccessQueue() {
        return new Queue("credit_adjust_success_queue");
    }

    // 将Queue绑定到Exchange
    @Bean
    public Binding bindingActivitySkuStockZero(Queue activitySkuStockZeroQueue, TopicExchange activitySkuStockZeroExchange) {
        return BindingBuilder.bind(activitySkuStockZeroQueue).to(activitySkuStockZeroExchange).with("activity_sku_stock_zero");
    }

    @Bean
    public Binding bindingSendAward(Queue sendAwardQueue, TopicExchange sendAwardExchange) {
        return BindingBuilder.bind(sendAwardQueue).to(sendAwardExchange).with("send_award");
    }

    @Bean
    public Binding bindingSendRebate(Queue sendRebateQueue, TopicExchange sendRebateExchange) {
        return BindingBuilder.bind(sendRebateQueue).to(sendRebateExchange).with("send_rebate");
    }

    @Bean
    public Binding bindingCreditAdjustSuccess(Queue creditAdjustSuccessQueue, TopicExchange creditAdjustSuccessExchange) {
        return BindingBuilder.bind(creditAdjustSuccessQueue).to(creditAdjustSuccessExchange).with("credit_adjust_success");
    }
}
